import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const sysUserApi = {
  sysUserAdd: '/sys/admin/add',
  sysUserList: '/sys/admin/list',
  sysUserListJson: '/sys/admin/listJson',
  sysUserDetail: '/sys/admin/detail',
  sysUserTokenInfo: '/sys/admin/info',
  sysUserUpdate: '/sys/admin/update',
  sysAdminUpdate: '/sys/admin/updateAccount',
  sysUserDisable: '/sys/admin/disable',
  sysUpdatePassword: '/sys/admin/updatePwdByOldPwd',
  sysResetPassword: '/sys/admin/resetPassword',
};

export const getUserListJson = () => {
  return request({
    url: sysUserApi.sysUserListJson,
    method: RequestEnum.GET,
  });
};

export const disableUser = (id: number) => {
  return request({
    url: `${sysUserApi.sysUserDisable}?id=${id}`,
    method: RequestEnum.POST,
  });
};

export const getUserInfo = () => {
  return request({
    url: sysUserApi.sysUserTokenInfo,
    method: RequestEnum.GET,
  });
};

export const updateUser = (data: API.UpdateAdminInfoParams) => {
  return request({
    url: sysUserApi.sysUserUpdate,
    method: RequestEnum.POST,
    data,
  });
};

export const updateAdminInfo = (data: API.UpdateAdminInfoParams) => {
  return request({
    url: sysUserApi.sysAdminUpdate,
    method: RequestEnum.POST,
    data,
  });
};

export const resetUserPassword = (data: API.ResetPasswordParams) => {
  return request({
    url: sysUserApi.sysResetPassword,
    method: RequestEnum.POST,
    data,
  });
};

export const updateUserPassword = (data: API.UpdatePasswordParams) => {
  return request({
    url: sysUserApi.sysUpdatePassword,
    method: RequestEnum.POST,
    data,
  });
};

export const createUser = (data: API.CreateUserParams) => {
  return request({
    url: sysUserApi.sysUserAdd,
    method: RequestEnum.POST,
    data,
  });
};
